package com.yc.spring.mvc.controller;

import java.util.Map;

import javax.servlet.http.HttpSession;

import com.yc.spring.mvc.bean.UserInfo;
import com.yc.spring.mvc.core.annotation.Autowired;
import com.yc.spring.mvc.core.annotation.Controller;
import com.yc.spring.mvc.core.annotation.RequestMapping;
import com.yc.spring.mvc.core.annotation.RequestParam;
import com.yc.spring.mvc.core.annotation.ResponseBody;
import com.yc.spring.mvc.service.impl.UserInfoServiceImpl;

@Controller
@RequestMapping("/user")
public class UserInfoController {
	@Autowired
	private UserInfoServiceImpl userInfoService;
	
	@RequestMapping("/login")
	public String login() {
		System.out.println("进来了...");
		return "redirect:/index.html";
	}
	
	@RequestMapping("/reg1")
	@ResponseBody //以json格式返回
	public UserInfo reg1() {
		return new UserInfo(1001,"yc", "123456");
	}
	
	@RequestMapping("/reg")
	@ResponseBody //以json格式返回
	public UserInfo reg(UserInfo uf) {
		System.out.println(userInfoService);
		System.out.println(uf);
		return uf;
	}
	
	@RequestMapping("/find2")
	@ResponseBody //以json格式返回
	public int find2(@RequestParam("uid") Integer usid, String uname, String tel) {
		System.out.println(usid + "\t" + uname + "\t" + tel);
		return 1;
	}
	
	@RequestMapping("/find")
	public String reg(Map<String, Object> map, HttpSession session) {
		System.out.println(map);
		System.out.println(session);
		return "redirect:/a.html";
	}
	
}
